package cumeo89.chii.client.ui;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;

public class TrivialPanel extends ComplexPanel implements ExtendedPanel {

	public TrivialPanel(String tag) {
		Element elem = DOM.createElement(tag);
		setElement(elem);
	}

	public TrivialPanel(String tag, String html) {
		this(tag);
		setHTML(html);
	}

	public TrivialPanel(Element elem) {
		setElement(elem);
	}

	public void setHTML(String html) {
		DOM.setInnerHTML(getElement(), html);
	}

	@Override
	public void add(Widget child) {
		super.add(child, getElement());
	}

	public void insert(Widget newChild, int index) {
		super.insert(newChild, getElement(), index, true);
	}

	public void insert(Widget newChild, Widget beforeChild) {
		if (beforeChild == null) {
			add(newChild);
		} else {
			insert(newChild, getWidgetIndex(beforeChild));
		}
	}

}
